from django.contrib import admin
from .models import *

# Register your models here.

@admin.register(DatasetMold)
class DatasetMoldAdmin(admin.ModelAdmin):
    list_display = ["name", "classname", "class_status", "desc", "note", "update_dt"]
    list_filter = []

    def class_status(self, obj):
        if obj.mold_class:
            return 'OK'
        else:
            return 'Failed'


@admin.register(DataSet)
class DataSetAdmin(admin.ModelAdmin):
    list_display = ["name", "desc", "creator", "mold", "obj_status", "public", "free", "depot", "root_path", "size"]
    list_filter = ["public", "free", "creator", "mold", "depot"]
    filter_horizontal = ['tags']

    def obj_status(self, obj):
        if obj.dataset:
            return 'OK'
        else:
            return 'Failed'


@admin.register(DatasetTag)
class DatasetTagAdmin(admin.ModelAdmin):
    list_display = ['name']


@admin.register(User_Data)
class User_DataAdmin(admin.ModelAdmin):
    list_display = ['key', 'create_dt']


@admin.register(UserDataSetting)
class UserDataSettingAdmin(admin.ModelAdmin):
    list_display = ['user', 'data_limit_per_day', 'ignore_sample']
    filter_horizontal = ['accessible_datasets', 'free_datasets']
